package service.impl;

import java.util.List;

import dao.impl.UserDaoImpl;
import entity.Users;
import service.IUserService;

public class UserServiceImpl implements IUserService{
	UserDaoImpl dao=new UserDaoImpl();
	public List<Users> QueryAllUsers(){
		return dao.Select_All();
	}

	public Users SelectByID(int UID) {//根据ID查询数据
		return dao.SelectByID(UID);
	}
	public Users SelectByID(String name) {//根据ID查询数据
		return dao.SelectByID(name);
	}
	public Boolean UpdateByID(int Uid,Users user) {//根据ID修改数据
		if(dao.IsExsist(Uid)) {
			return dao.Update(Uid, user);
		}
		return false;
	}
	public Boolean DeleteByID(int uid) {//根据ID删除数据
		if(dao.IsExsist(uid)) {
			return dao.Delete(uid);
		}
		return false;
	}
	public Boolean addUser(Users user ) {//添加数据
		if(!dao.IsExsist(user.getUName())){
			dao.Add(user);
			return true;
		}else {
			System.out.println("此人已存在！");
			return false;
		}
	}

	@Override
	public List<Users> querybypage(int pageindex, int pagesize) {
		
		//分页
		return dao.queryusersbypage(pageindex, pagesize);
	}

	@Override
	public int GetAllCount() {
		// 获取数据
		return dao.GetAllCount();
	}
}
